home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 1.5)
-
- import zlib
- import sys
- import imp
- import string
-
- try:
- t = imp.find_module('test_zlib')
- file = t[0]
- except ImportError:
- file = open(__file__)
-
- buf = file.read() * 8
- file.close()
- print hex(zlib.crc32('penguin')), hex(zlib.crc32('penguin', 1))
- print hex(zlib.adler32('penguin')), hex(zlib.adler32('penguin', 1))
-
- try:
- zlib.compress('ERROR', zlib.MAX_WBITS + 1)
- except zlib.error:
- msg = None
- print 'expecting', msg
-
-
- try:
- zlib.compressobj(1, 8, 0)
- except ValueError:
- msg = None
- print 'expecting', msg
-
-
- try:
- zlib.decompressobj(0)
- except ValueError:
- msg = None
- print 'expecting', msg
-
- x = zlib.compress(buf)
- y = zlib.decompress(x)
- if buf != y:
- print 'normal compression/decompression failed'
- else:
- print 'normal compression/decompression succeeded'
- buf = buf * 16
- co = zlib.compressobj(8, 8, -15)
- x1 = co.compress(buf)
- x2 = co.flush()
- x = x1 + x2
- dc = zlib.decompressobj(-15)
- y1 = dc.decompress(x)
- y2 = dc.flush()
- y = y1 + y2
- if buf != y:
- print 'compress/decompression obj failed'
- else:
- print 'compress/decompression obj succeeded'
- co = zlib.compressobj(2, 8, -12, 9, 1)
- bufs = []
- for i in range(0, len(buf), 256):
- bufs.append(co.compress(buf[i:i + 256]))
-
- bufs.append(co.flush())
- combuf = string.join(bufs, '')
- decomp1 = zlib.decompress(combuf, -12, -5)
- if decomp1 != buf:
- print 'decompress with init options failed'
- else:
- print 'decompress with init options succeeded'
- deco = zlib.decompressobj(-12)
- bufs = []
- for i in range(0, len(combuf), 128):
- bufs.append(deco.decompress(combuf[i:i + 128]))
-
- bufs.append(deco.flush())
- decomp2 = string.join(buf, '')
- if decomp2 != buf:
- print 'decompressobj with init options failed'
- else:
- print 'decompressobj with init options succeeded'
- for sync in [
- zlib.Z_NO_FLUSH,
- zlib.Z_SYNC_FLUSH,
- zlib.Z_FULL_FLUSH]:
- for level in range(10):
- obj = zlib.compressobj(level)
- d = obj.compress(buf[:3000])
- d = d + obj.flush(sync)
- d = d + obj.compress(buf[3000:])
- d = d + obj.flush()
- del obj
-
-
-
- def ignore():
- '''An empty function with a big string.
-
- Make the compression algorithm work a little harder.
- '''
- pass
-
-